package com.yanqu.road.server.gameplayer.module.activity.horserun.event;

import com.yanqu.road.entity.activity.horserun.HorseRunUserGamingData;
import com.yanqu.road.entity.activity.horserun.config.HorseRunEventConfig;
import com.yanqu.road.logic.activity.horserun.HorseRunConfig;
import com.yanqu.road.pb.activity.HorseRunProto;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * show("表演事件,遇到直接获得刷新道具",3)
 */
public class HorseRunShowEvent extends HorseRunBaseEvent{
    @Override
    public HorseRunProto.EventResult.Builder meet(HorseRunUserGamingData userGamingData, HorseRunConfig config, HorseRunEventConfig eventConfigById) {
        HorseRunProto.EventResult.Builder builder = HorseRunProto.EventResult.newBuilder();
        int eventId = eventConfigById.getId();
        builder.setError(0);

        addUserLog(userGamingData,config,1,eventId,new ArrayList<>(),builder);
        eventNoDeal(userGamingData);
        return builder;
    }

    @Override
    public HorseRunProto.EventResult.Builder deal(HorseRunUserGamingData userGamingData, HorseRunDealEventArg arg, HorseRunConfig config, HorseRunEventConfig eventConfigById) {
        HorseRunProto.EventResult.Builder builder = HorseRunProto.EventResult.newBuilder();
        int eventId = eventConfigById.getId();


        builder.setError(0);
        int goodId = config.getRefreshEntryItem();
        int goodNum = eventConfigById.getParamList().get(1);

        goodNum = goodNum * userGamingData.getOpenGameMultiple();

        Property reward = new Property(goodId,goodNum);

        String goodReward = PropertyHelper.parsePropertyToString(reward);

        builder.addGoodReward(goodReward);

        List<Integer> logParam = new ArrayList<>();
        logParam.add(goodId);
        logParam.add(goodNum);

        addUserLog(userGamingData,config,2,eventId,logParam,builder);
        eventDone(userGamingData);

        return builder;
    }
}
